Adds a range of items to the collection
Syntax
Example
Library/Library.Test/TestSetList.cs
C# | Copy Code |
---|
SetList<int> list = new SetList<int>();
list.AddRange(new int[] { 5, 10, 20 });
ICollection coll = list;
Assert.IsFalse(coll.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(coll, coll.SyncRoot));
int[] copy = new int[3];
coll.CopyTo(copy, 0);
Assert.AreEqual(5, copy[0]);
Assert.AreEqual(10, copy[1]);
Assert.AreEqual(20, copy[2]);
List<int> tmp = new List<int>();
foreach (int i in coll)
tmp.Add(i);
Assert.AreEqual(3, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
Assert.AreEqual(20, tmp[2]); |
VB.NET | Copy Code |
---|
Dim list As New SetList(Of Integer)()
list.AddRange(New Integer() {5, 10, 20})
Dim coll As ICollection = list
Assert.IsFalse(coll.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(coll, coll.SyncRoot))
Dim copy As Integer() = New Integer(3) {}
coll.CopyTo(copy, 0)
Assert.AreEqual(5, copy(0))
Assert.AreEqual(10, copy(1))
Assert.AreEqual(20, copy(2))
Dim tmp As New List(Of Integer)()
For Each i As Integer In coll
tmp.Add(i)
Next
Assert.AreEqual(3, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))
Assert.AreEqual(20, tmp(2)) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also